<?php
 
include_once("./configure/configure.php");						//--> global var
include_once("./admin/tools/smarty/libs/Smarty.class.php");		//--> out template
include_once("./admin/lib/utils/StringUtils.php");				//--> String utils
include_once("./admin/lib/utils/StyleUtils.php");				//--> Style utils
include_once("./admin/lib/utils/FileUtils.php");				//--> file utils


include_once("includeSmarty.php");

$firstLetter = $_GET['firstLetter'];

$cacheId = $firstLetter;

/*----- out html -----*/
$SUB_DIR	= FileUtils::getDirByString($firstLetter) . '/';

$smarty->compile_dir  	= COMPILE_DIR . '/mer/' . $SUB_DIR;
$smarty->cache_dir  	= CACHE_DIR . '/mer/' . $SUB_DIR;


if(!$smarty->isCached('merchants.html', $cacheId, $cacheId)){
	$oStringUtils = new StringUtils();
	
	include_once("includeTag.php");
	include_once("includeMerchant.php");
	include_once("includeCategories.php");
	
	
	if(!ereg('^[a-zA-Z]+$', $firstLetter)){
		$firstLetter = '#';
	}
	
	$oMerchantsFeatured = $oMerchantImpl->getFeaturedMerchants($firstLetter, 0, 8);
	$oMerchantsFLetter 	= $oMerchantImpl->getMerchantsByFirstLetter($firstLetter);
	
	foreach ($oMerchantsFeatured as $oMerchant) {
		$oLogo 	= $oMerchantImpl->getLogo($oMerchant->getId());
		
		if(!is_object($oLogo)){
			$oLogo = new ImageDomain();
			
			$oLogo->setId(0);
			$oLogo->setExtName('gif');
		}
		
		$oMerchant->setLogo($oLogo);
		
	}
	
	$smarty->assign('oMerchantsFeatured', $oMerchantsFeatured);
	$smarty->assign('oMerchantsFLetter', $oMerchantsFLetter);
	$smarty->assign('oCategories', $oCategories);
	
	$smarty->assign('oMerchants', $oMerchants);
	$smarty->assign('oTags', $oTags);
	

}

$smarty->assign('HOME_URL', HOME_URL);
$smarty->assign('HOME_URL_HTTP', HOME_URL_HTTP);

$smarty->assign('theme', StyleUtils::getTheme());

$smarty->display('merchants.html', $cacheId, $cacheId);
?>
